﻿using GameFramework;
using UnityEngine;
using System;

namespace MYSTARFORCE {
    /// <summary>
    /// 子弹的逻辑
    /// </summary>
    [Serializable]
    public class Bullet : AccessoryObject
    {
        [SerializeField]
        private BulletData m_BulletData = null;

        public ImpactData GetImpactData()
        {
            return new ImpactData(m_BulletData.OwnerCamp, 0, m_BulletData.Attack, 0);
        }

        protected override void OnShow(object userData)
        {
            base.OnShow(userData);

            m_BulletData = userData as BulletData;
            if(m_BulletData == null)
            {
                Log.Warning("Bullet Data is invalid");
                return;
            }
        }

        protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
        {
            base.OnUpdate(elapseSeconds, realElapseSeconds);

            // 一直向上移动
            CachedTransform.Translate(Vector3.forward * m_BulletData.Speed * elapseSeconds, Space.World);
        }
    }
}